import { ProFormUploadButton } from '@ant-design/pro-components';
import type { ProFormUploadButtonProps } from '@ant-design/pro-components';
import { message } from 'antd';
import { getToken } from '@/utils/auth';
const BaseUpload = (props: ProFormUploadButtonProps) => {
  const { fieldProps, ...rest } = props;
  return (
    <ProFormUploadButton
      {...rest}
      action="/xfj/file/uploadPictureFile"
      fieldProps={{
        ...fieldProps,
        onChange: ({ file }) => {
          if (file.response?.success === false) {
            message.error(file.response.msg);
            file.status = 'error';
          }
        },
        headers: {
          Authorization: getToken() as string,
        },
      }}
    />
  );
};
export default BaseUpload;
